package com.eventbus.demo.guava;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class GuavaEventBus {
    private  static EventBus syncEventBus = new EventBus("Sync-Event-Bus");
    //DeadEvent
    private  static EventBus asyncEventBus = new AsyncEventBus(Executors.newCachedThreadPool());
    public static void main(String[] args) throws InterruptedException {
        syncEventBus.register(new EventListener());
        asyncEventBus.register(new EventListener());
        System.out.println("publishing event ... ");
        syncEventBus.post("this is a sync event");
        asyncEventBus.post("this is a async event");
        TimeUnit.SECONDS.sleep(5);
    }
}
